home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils text / ReadDocJ 1.1 / ReadDocJ.exe / Source / HorizontalButtons.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  1.5 KB  |  62 lines

  1. import java.awt.*;
  2. import java.util.*;
  3. import javax.swing.*;
  4.  
  5. /**
  6.  * <code>HorizontalButtons</code> class layout a button panel in a horizontal orientation
  7.  * @author Jeffrey A. Krzysztow
  8.  * @author Steven R. Brandt
  9.  * @version 1.0
  10.  */
  11. public class HorizontalButtons extends JPanel {
  12.     /**
  13.      * Constructs a horizontal button panel
  14.      * @since 1.0
  15.      */
  16.     HorizontalButtons() {
  17.         setLayout(gbl);
  18.         gbc.fill = gbc.BOTH;
  19.         gbc.gridy = 0;
  20.         gbc.gridx = 0;
  21.     }
  22.  
  23.     /**
  24.      * adds a button in the next location
  25.      * @param button button to add
  26.      * @since 1.0
  27.      */
  28.     public void add(JButton button) {
  29.         super.add(button);
  30.         bv.addElement(button);
  31.         gbl.setConstraints(button, gbc);
  32.         gbc.gridx++;
  33.     }
  34.  
  35.     /**
  36.      * Enables or disables all the button, depending on the value of the parameter b.
  37.      * @param b if true, buttons are enable, otherwise they are disabled
  38.      * @since 1.0
  39.      */
  40.     public void setEnabled(boolean b) {
  41.         for(int i = 0; i < bv.size(); i++) {
  42.             ((JButton)bv.elementAt(i)).setEnabled(b);
  43.         }
  44.     }
  45.  
  46.     /**
  47.      * Enables or disables the button, depending on the value of the parameter b.
  48.      * @param b     if true, buttons are enable, otherwise they are disabled
  49.      * @param index which button
  50.      * @since 1.0
  51.      */
  52.     public void setEnabled(boolean b, int index) {
  53.         ((JButton)bv.elementAt(index)).setEnabled(b);
  54.     }
  55.  
  56.     private GridBagLayout gbl = new GridBagLayout();
  57.     private GridBagConstraints gbc = new GridBagConstraints();
  58.     private Vector bv = new Vector();
  59.  
  60. }
  61.  
  62.